package com.hsc.www.mybatis.soEasy.yy;

import java.util.Arrays;
import java.util.stream.Collectors;

public enum UserEntity implements ResultColumn {
    userId("user_id", true),
    userName("user_name", false);
    private static UserEntity[] allColumns;
    private static UserEntity[] blobColumns;
    private static UserEntity[] noBlobColumns;

    private String column;
    private Boolean blob;

    UserEntity(String column, boolean blob) {
        this.column = column;
        this.blob = blob;
    }

    @Override
    public String getColumn() {
        return this.column;
    }

    public Boolean getBlob() {
        return blob;
    }


    public static UserEntity[] getAllColumns() {
        if (allColumns == null) {
            allColumns = UserEntity.values();
        }
        return allColumns;
    }

    public static UserEntity[] getBlobColumns() {
        if (blobColumns == null) {
            UserEntity[] allColumns = getAllColumns();
            blobColumns = Arrays.stream(allColumns).filter(column -> column.getBlob()).collect(Collectors.toList()).toArray(new UserEntity[]{});
        }
        return blobColumns;
    }

    public static UserEntity[] getNoBlobColumns() {
        if (noBlobColumns == null) {
            UserEntity[] allColumns = getAllColumns();
            noBlobColumns = Arrays.stream(allColumns).filter(column -> !column.getBlob()).collect(Collectors.toList()).toArray(new UserEntity[]{});
        }
        return noBlobColumns;
    }
}
